package com.spirng.leetcode.day01;

public class Array3_2 {
    public static void main(String[] args) {
        moveZeroes(new int[]{1,0,1,0,3,12});
    }
    public static void moveZeroes(int[] nums) {
      int slow=0;
      int fast=0;
      int num=0;
      for (;fast< nums.length;fast++){
          if(nums[fast]!=0){
              nums[slow++]=nums[fast];
          }
          if (nums[fast]==0)
            num++;
      }
      for (int j=nums.length-1;j>=0&&num>0;j--,num--){
          nums[j]=0;
      }
    }
}
